package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.dto.NursingProjectPlanDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "护理计划相关接口")
@RequiredArgsConstructor
@RequestMapping("/nursing/plan")
public class NursingPlanController {

    private final NursingPlanService nursingPlanService;

    @GetMapping()
    @ApiOperation(value = "查询所有护理计划")
    public ResponseResult selectAll() {
        List<NursingPlanVo> nursingPlanVo = nursingPlanService.findAll();
        return ResponseResult.success(nursingPlanVo);
    }
    @PostMapping()
    @ApiOperation(value = "新增护理计划")
    public ResponseResult addNursingPlan(@RequestBody NursingPlanDto nursingPlanDto) {
        nursingPlanService.addNursingPlan(nursingPlanDto);
        return ResponseResult.success();
    }
    @GetMapping("/search")
    @ApiOperation(value = "分页查询护理计划")
    public ResponseResult selectPage(String name,Integer status,Integer pageNum,Integer pageSize) {
        PageResponse<NursingPlanVo> nursingPlanVoPageResponse = nursingPlanService.selectPage(name,status,pageNum,pageSize);
        return ResponseResult.success(nursingPlanVoPageResponse);
    }
    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理计划")
    public ResponseResult selectById(@PathVariable("id") Long id) {
        NursingPlanVo nursingPlanVo = nursingPlanService.selectById(id);
        return ResponseResult.success(nursingPlanVo);
    }
    @PutMapping()
    @ApiOperation(value = "修改护理计划")
    public ResponseResult updateNursingPlan(@RequestBody NursingPlanDto nursingPlanDto) {
        nursingPlanService.updateNursingPlan(nursingPlanDto);
        return ResponseResult.success();
    }
    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除护理计划")
    public ResponseResult deleteById(@PathVariable("id") Long id) {
        nursingPlanService.deleteById(id);
        return ResponseResult.success();
    }
    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "禁用启用护理计划")
    public ResponseResult startOrStop(@PathVariable Long id,@PathVariable Integer status) {
        nursingPlanService.startOrStop(id,status);
        return ResponseResult.success();
    }
}
